struct ListNode* removeElements(struct ListNode* head, int val)
{
  while (NULL != head && head->val == val)
  {
      head = head->next;
  }

  struct ListNode* curr=head;
  struct ListNode* prev=NULL;
  while(curr!=NULL)
  {
      if(curr->val!=val)
      {
          prev=curr;
      }
      else
      {
          prev->next=curr->next;
      }
      curr=curr->next; 
  }
  return head;
}